package com.joysuch.wwyt.bp.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.joysuch.wwyt.bp.bean.BpPermitsBean;
import com.joysuch.wwyt.bp.entity.BpPermits;
import com.joysuch.wwyt.bp.service.BpPermitsService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "数据权限")
@RequestMapping("/bp/permits")
public class BpPermitsController {

    @Autowired
    private BpPermitsService permitsService;


    @GetMapping("page")
    public ResultBean page(Pageable page){
        Page<BpPermits> data = permitsService.page(page);
        return ResultBean.pageData(data.getContent(), data.getTotalElements());
    }

    @PostMapping("delete")
    public ResultBean delete(Long id){
        permitsService.delete(id);
        return ResultBean.defaultSuccessResult();
    }

    @PostMapping("add")
    public ResultBean add(@RequestBody BpPermitsBean bpPermits) throws JsonProcessingException {
        permitsService.add(bpPermits);
        return ResultBean.defaultSuccessResult();
    }







}
